﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CuitHtmlEditableDiv.cs" company="">
//   
// </copyright>
// <summary>
//   The cuit html editable div.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace UITest.CUIT.CuitControls.HtmlControls
{
    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;

    /// <summary>
    /// The cuit html editable div.
    /// </summary>
    public class CuitHtmlEditableDiv : CuitHtmlControl<HtmlEditableDiv>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitHtmlEditableDiv"/> class.
        /// </summary>
        public CuitHtmlEditableDiv()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitHtmlEditableDiv"/> class.
        /// </summary>
        /// <param name="testControl">
        /// The test control.
        /// </param>
        public CuitHtmlEditableDiv(UITestControl testControl)
            : base(testControl)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitHtmlEditableDiv"/> class.
        /// </summary>
        /// <param name="testControl">
        /// The test control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        public CuitHtmlEditableDiv(UITestControl testControl, string searchProperties)
            : base(testControl, searchProperties)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitHtmlEditableDiv"/> class.
        /// </summary>
        /// <param name="testControl">
        /// The test control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        /// <param name="filterProperties">
        /// The filter properties.
        /// </param>
        public CuitHtmlEditableDiv(UITestControl testControl, string searchProperties, string filterProperties)
            : base(testControl, searchProperties, filterProperties)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitHtmlEditableDiv"/> class.
        /// </summary>
        /// <param name="wrappedControl">
        /// The wrapped control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        /// <param name="filterProperties">
        /// The filter properties.
        /// </param>
        public CuitHtmlEditableDiv(ICuitControlBase wrappedControl, string searchProperties, string filterProperties)
            : base(wrappedControl, searchProperties, filterProperties)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CuitHtmlEditableDiv"/> class.
        /// </summary>
        /// <param name="wrappedControl">
        /// The wrapped control.
        /// </param>
        /// <param name="searchProperties">
        /// The search properties.
        /// </param>
        public CuitHtmlEditableDiv(ICuitControlBase wrappedControl, string searchProperties)
            : base(wrappedControl, searchProperties)
        {
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///     Gets a value indicating whether read only.
        /// </summary>
        public bool ReadOnly
        {
            get
            {
                this._control.WaitForControlReady();
                return this._control.ReadOnly;
            }
        }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        ///     The get text.
        /// </summary>
        /// <returns>
        ///     The <see cref="string" />.
        /// </returns>
        public string GetText()
        {
            this._control.WaitForControlReady();
            return this._control.Text;
        }

        /// <summary>
        /// The set text.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        public void SetText(string text)
        {
            this._control.WaitForControlReady();
            this._control.Text = text;
            this.WriteTestOutput("Typing " + text + " on ");
        }

        #endregion
    }
}